import React, { Component } from 'react';
import { connect } from 'react-redux'
import actions from '../../../store/actions';
class Index extends Component {
  render() {
    const { list } = this.props
    return (
      <div>
        <ul>
          {
            list.length > 0 && list.filter(v => v.isCollect).map((v,i ) => {
              return (
                <li key={i}>
                  <h3>{ v.title }</h3>
                  {/* 切换收藏 */}
                  <button onClick={ () => this.props.dispatch(actions.setCollect(v)) }>取消收藏</button>
                </li>
              )
            })
          }
        </ul>
      </div>
    );
  }
}

const mapState = state => state
const mapDiaptch = dispatch => ({ dispatch })

export default connect(mapState,mapDiaptch)(Index);
